
/*
class Ball
  constructor: (@color, @point) -> #
class Point
  constructor: (@x, @y) -> #
  bounce: -> puts "hello"
multer = (m) -> ((x) -> x*m)
tripler = multer(3)
alert tripler(10)
*/

(function() {
  var Ball,
    __hasProp = Object.prototype.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

  Ball = (function(_super) {

    __extends(Ball, _super);

    function Ball(color) {
      this.color = color;
    }

    return Ball;

  })(Object);

  $(function() {
    var handleHelper, reflowContent, resetValue, scrollContent, scrollPane, scrollbar, sizeScrollbar;
    $(".idea").draggable({
      drag: function(event, ui) {
        return $.notification("(" + ui.position.top + ", " + ui.position.left + ")", {
          position: "bottom-right"
        });
      }
    });
    $("#dialog").dialog();
    $.ajax({
      url: "batman",
      type: "POST",
      data: {
        text: "Hello you"
      },
      success: function(data) {
        return $.notification(data);
      }
    });
    $.ajax({
      url: "ideasdata",
      dataType: "json",
      timeout: 5000,
      success: function(data) {
        $("#dialog").append("<h3>Data received</h3>\n<p>" + data.notes + "</p>");
        return _.each(data.notes, function(caption) {
          $("#ideatable").append("<div class='idea ui-widget-content'>" + caption + "</div>");
          $(".idea").dblclick(function() {
            return alert("you clickd me");
          });
          return $(".idea").draggable();
        });
      },
      error: function(jqXHR, textStatus, errorThrown) {
        return $("#dialog").append("<h3>" + textStatus + "</h3>\n<p>" + errorThrown + "</p>");
        /*
              $.notification textStatus,
                className: "jquery-notification"
                duration: 2000
                freezeOnHover: true
                hideSpeed: 250
                position: 'center'
                showSpeed: 250
                zIndex: 99999
        */
      }
    });
    sizeScrollbar = function() {
      var handleSize, proportion, remainder;
      remainder = scrollContent.width() - scrollPane.width();
      proportion = remainder / scrollContent.width();
      handleSize = scrollPane.width() - (proportion * scrollPane.width());
      scrollbar.find(".ui-slider-handle").css({
        width: handleSize,
        "margin-left": -handleSize / 2
      });
      return handleHelper.width("").width(scrollbar.width() - handleSize);
    };
    resetValue = function() {
      var leftVal, percentage, remainder;
      remainder = scrollPane.width() - scrollContent.width();
      leftVal = (scrollContent.css("margin-left") === "auto" ? 0 : parseInt(scrollContent.css("margin-left")));
      percentage = Math.round(leftVal / remainder * 100);
      return scrollbar.slider("value", percentage);
    };
    reflowContent = function() {
      var gap, showing;
      showing = scrollContent.width() + parseInt(scrollContent.css("margin-left"), 10);
      gap = scrollPane.width() - showing;
      if (gap > 0) {
        return scrollContent.css("margin-left", parseInt(scrollContent.css("margin-left"), 10) + gap);
      }
    };
    scrollPane = $(".scroll-pane");
    scrollContent = $(".scroll-content");
    scrollbar = $(".scroll-bar").slider({
      slide: function(event, ui) {
        if (scrollContent.width() > scrollPane.width()) {
          return scrollContent.css("margin-left", Math.round(ui.value / 100 * (scrollPane.width() - scrollContent.width())) + "px");
        } else {
          return scrollContent.css("margin-left", 0);
        }
      }
    });
    handleHelper = scrollbar.find(".ui-slider-handle").mousedown(function() {
      return scrollbar.width(handleHelper.width());
    }).mouseup(function() {
      return scrollbar.width("100%");
    }).append("<span class='ui-icon ui-icon-grip-dotted-vertical'></span>").wrap("<div class='ui-handle-helper-parent'></div>").parent();
    scrollPane.css("overflow", "hidden");
    $(window).resize(function() {
      resetValue();
      sizeScrollbar();
      return reflowContent();
    });
    return setTimeout(sizeScrollbar, 10);
  });

}).call(this);
